﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Business.Models;
using ETL.Common.Logging;
using ETL.DataAccess;

namespace ETL.Business.Handlers.ProjectActualResourceHandler
{
    public class DeleteActualResourceUsages
    {
        private readonly ProjectActualResourceUsageRepository _projectActualResourceRepository;
        private readonly ProjectTaskRepository _projectTaskRepository;

        public DeleteActualResourceUsages(ProjectActualResourceUsageRepository projectActualResourceRepository)
        {
            _projectActualResourceRepository = projectActualResourceRepository;
        }

        public DeleteActualResourceUsages()
        {
            _projectActualResourceRepository = new ProjectActualResourceUsageRepository();
            _projectTaskRepository = new ProjectTaskRepository();
        }

        public virtual void Execute( string taskId)
        {
            try
            {
                // set latest from DB  DateTime dt, float hours
                _projectActualResourceRepository.DeleteActualResourceUsages(taskId);
                
            }
            catch (Exception ex)
            {
                LogService.Service.Debug(ex);
            }
        }

        public virtual void Execute(ProjectTaskModel task)
        {
            try
            {
                Execute(task.TaskId.ToString());

            }
            catch (Exception ex)
            {
                LogService.Service.Debug(ex);
            }
        }
    }
}
